#include "KNN.h"
#include "Toolkit.h"
#include "SampleSpace.h"

#include <cfloat>
#include <fstream>

class Sample;

void KNN::train(vector<Sample *> &sampleList) {
    assert(sampleList.size() > 0);

    if(m_copyList) {
        releaseSampleList();

        m_sampleList = new vector<Sample *>;

        int size = sampleList.size();
        m_sampleSpace->newSampleArray(*m_sampleList, size);

        for (int i = 0; i < size; i++) {
            m_sampleSpace->copy(*m_sampleList->at(i), *sampleList.at(i));
        }
    } else {
        m_sampleList = &sampleList;
    }
}
